﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeftFork.TestHelpers
{
    public class RandomData
    {
        public static string RandomAlphaString()
        {
            return RandomAlphaString(1, 2000);
        }
        public static string RandomAlphaString(int minLength, int maxLength)
        {
            char[] values = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
            return random_string(values, minLength, maxLength);
        }

        public static string RandomAlphaNumString()
        {
            return RandomAlphaNumString(1, 2000);
        }
        public static string RandomAlphaNumString(int minLength, int maxLength)
        {
            char[] values = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
            return random_string(values, minLength, maxLength);
        }

        public static string RandomNumString()
        {
            return RandomNumString(1, 2000);
        }
        public static string RandomNumString(int minLength, int maxLength)
        {
            char[] values = "1234567890".ToCharArray();
            return random_string(values, minLength, maxLength);
        }

        private static string random_string(char[] pool, int minLength, int maxLength)
        {
            StringBuilder result = new StringBuilder();
            int length = RandomInt(minLength, maxLength);
            var rand = new Random();
            int valuesLength = pool.Length;
            for (int i = 0; i < length; i++)
            {
                result.Append(pool[rand.Next(valuesLength - 1)]);
            }

            return result.ToString();
        }

        public static int RandomInt()
        {
            return RandomInt(0, Int32.MaxValue);
        }
        public static int RandomInt(int min, int max)
        {
            var rand = new Random();
            return rand.Next(min, max);
        }
    }
}
